package consultan.vanke.com.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import consultan.vanke.com.R;
import consultan.vanke.com.adapter.CommonAdapter;
import consultan.vanke.com.adapter.ViewHolder;
import consultan.vanke.com.bean.HomeJumpBean;
import consultan.vanke.com.constant.ConstantLibrary;
import consultan.vanke.com.event.MessageEvent;
import consultan.vanke.com.utils.SimpleToolbar;
import qiu.niorgai.StatusBarCompat;

import static com.bytedance.sdk.account.open.aweme.utils.ViewUtils.getStatusBarHeight;
import static consultan.vanke.com.utils.StatusBarUtil.setPaddingTop;
import static consultan.vanke.com.utils.StatusBarUtil.setRootView;


public class JiesuanFragment extends BaseFragment {
    @BindView(R.id.lienar_top)
    LinearLayout lienarTop;
    @BindView(R.id.linear_center)
    LinearLayout linearCenter;
    @BindView(R.id.recy_list)
    RecyclerView recyList;
    @BindView(R.id.btn_login)
    LinearLayout btnLogin;
    @BindView(R.id.btn_ok)
    Button btnOk;
    private View inflate;
    private boolean isfristshow = true;
    @BindView(R.id.simple_toolbar)
    SimpleToolbar simpleToolbar;
    @BindView(R.id.simple_toolbar_main)
    ConstraintLayout simpleToolbarMain;
    private CommonAdapter<String> adapterCenter;
    private List<String> subjectsBeansCenter = new ArrayList<>();

    @Override
    protected void initViews() {
        simpleToolbar.setMainTitle("提交订单");
    }

    @Override
    protected void initDatas() {
        for (int i = 0; i < 3; i++) {
            subjectsBeansCenter.add("111");
        }
        recyList.setLayoutManager(new LinearLayoutManager(_mActivity));
        adapterCenter = new CommonAdapter<String>(_mActivity, subjectsBeansCenter, R.layout.shangcheng_item_child) {
            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
            }

            @Override
            public void convert(ViewHolder holder, String assetBean) {
//                ImageView img_photo = holder.getView(R.id.img_photo);

            }

        };
        recyList.setAdapter(adapterCenter);
    }

    @Override
    protected void initEvents() {
        simpleToolbar.setLeftTitleClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
        simpleToolbar.setRightTitleAginClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(new JiesuanFragment());
            }
        });
    }

    @Override
    protected View initContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        inflate = View.inflate(_mActivity, R.layout.jiesuan_fragment, null);
        return inflate;
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        ViewGroup decorView = (ViewGroup) _mActivity.getWindow().getDecorView();
        View fakeStatusBarView = new View(_mActivity);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(_mActivity) + 3);
        fakeStatusBarView.setLayoutParams(params);
        fakeStatusBarView.setBackground(getResources().getDrawable(R.drawable.fast_regist_title_bg));
        fakeStatusBarView.setId(android.R.id.custom);
        decorView.addView(fakeStatusBarView);
        setRootView(_mActivity, false);
        if (isfristshow) {
            setPaddingTop(_mActivity, simpleToolbar);
            isfristshow = false;
        }
        StatusBarCompat.translucentStatusBar(_mActivity, true);
    }


    @OnClick(R.id.btn_ok)
    public void onViewClicked() {
        MessageEvent<HomeJumpBean> messageEvent = new MessageEvent<>();
        messageEvent.setData(new HomeJumpBean(ConstantLibrary.zhifuFragment, ConstantLibrary.TYPE_TIME_OUT));
        EventBus.getDefault().post(messageEvent);
    }
}
